﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace File_Operate_Program
{
    public class CEncodingList
    {
        private CEncodingList() { }
        public static CEncodingList _instance
        {
            get
            {
                if (CEncodingListinstance == null)
                {
                    lock (CEncodingListLock)
                    {
                        CEncodingListinstance = new CEncodingList();

                        int i = 0;
                        Dictionary<int, string> keyValuePairs = new Dictionary<int, string>();
                        i++;
                        keyValuePairs.Add(i, "37,IBM037,IBM EBCDIC (US-Canada)");
                        i++;
                        keyValuePairs.Add(i, "437,IBM437,OEM United States");
                        i++;
                        keyValuePairs.Add(i, "500,IBM500,IBM EBCDIC (International)");
                        i++;
                        keyValuePairs.Add(i, "708,ASMO-708,Arabic (ASMO 708)");
                        i++;
                        keyValuePairs.Add(i, "720,DOS-720,Arabic (DOS)");
                        i++;
                        keyValuePairs.Add(i, "737,ibm737,Greek (DOS)");
                        i++;
                        keyValuePairs.Add(i, "775,ibm775,Baltic (DOS)");
                        i++;
                        keyValuePairs.Add(i, "850,ibm850,Western European (DOS)");
                        i++;
                        keyValuePairs.Add(i, "852,ibm852,Central European (DOS)");
                        i++;
                        keyValuePairs.Add(i, "855,IBM855,OEM Cyrillic");
                        i++;
                        keyValuePairs.Add(i, "857,ibm857,Turkish (DOS)");
                        i++;
                        keyValuePairs.Add(i, "858,IBM00858,OEM Multilingual Latin I");
                        i++;
                        keyValuePairs.Add(i, "860,IBM860,Portuguese (DOS)");
                        i++;
                        keyValuePairs.Add(i, "861,ibm861,Icelandic (DOS)");
                        i++;
                        keyValuePairs.Add(i, "862,DOS-862,Hebrew (DOS)");
                        i++;
                        keyValuePairs.Add(i, "863,IBM863,French Canadian (DOS)");
                        i++;
                        keyValuePairs.Add(i, "864,IBM864,Arabic (864)");
                        i++;
                        keyValuePairs.Add(i, "865,IBM865,Nordic (DOS)");
                        i++;
                        keyValuePairs.Add(i, "866,cp866,Cyrillic (DOS)");
                        i++;
                        keyValuePairs.Add(i, "869,ibm869,Greek, Modern (DOS)");
                        i++;
                        keyValuePairs.Add(i, "870,IBM870,IBM EBCDIC (Multilingual Latin-2)");
                        i++;
                        keyValuePairs.Add(i, "874,windows-874,Thai (Windows)");
                        i++;
                        keyValuePairs.Add(i, "875,cp875,IBM EBCDIC (Greek Modern)");
                        i++;
                        keyValuePairs.Add(i, "932,shift_jis,Japanese (Shift-JIS)");
                        i++;
                        keyValuePairs.Add(i, "936,gb2312,Chinese Simplified (GB2312)");
                        i++;
                        keyValuePairs.Add(i, "949,ks_c_5601-1987,Korean");
                        i++;
                        keyValuePairs.Add(i, "950,big5,Chinese Traditional (Big5)");
                        i++;
                        keyValuePairs.Add(i, "1026,IBM1026,IBM EBCDIC (Turkish Latin-5)");
                        i++;
                        keyValuePairs.Add(i, "1047,IBM01047,IBM Latin-1");
                        i++;
                        keyValuePairs.Add(i, "1140,IBM01140,IBM EBCDIC (US-Canada-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1141,IBM01141,IBM EBCDIC (Germany-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1142,IBM01142,IBM EBCDIC (Denmark-Norway-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1143,IBM01143,IBM EBCDIC (Finland-Sweden-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1144,IBM01144,IBM EBCDIC (Italy-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1145,IBM01145,IBM EBCDIC (Spain-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1146,IBM01146,IBM EBCDIC (UK-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1147,IBM01147,IBM EBCDIC (France-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1148,IBM01148,IBM EBCDIC (International-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1149,IBM01149,IBM EBCDIC (Icelandic-Euro)");
                        i++;
                        keyValuePairs.Add(i, "1200,utf-16,Unicode");
                        i++;
                        keyValuePairs.Add(i, "1201,unicodeFFFE,Unicode (Big-Endian)");
                        i++;
                        keyValuePairs.Add(i, "1250,windows-1250,Central European (Windows)");
                        i++;
                        keyValuePairs.Add(i, "1251,windows-1251,Cyrillic (Windows)");
                        i++;
                        keyValuePairs.Add(i, "1252,Windows-1252,Western European (Windows)");
                        i++;
                        keyValuePairs.Add(i, "1253,windows-1253,Greek (Windows)");
                        i++;
                        keyValuePairs.Add(i, "1254,windows-1254,Turkish (Windows)");
                        i++;
                        keyValuePairs.Add(i, "1255,windows-1255,Hebrew (Windows)");
                        i++;
                        keyValuePairs.Add(i, "1256,windows-1256,Arabic (Windows)");
                        i++;
                        keyValuePairs.Add(i, "1257,windows-1257,Baltic (Windows)");
                        i++;
                        keyValuePairs.Add(i, "1258,windows-1258,Vietnamese (Windows)");
                        i++;
                        keyValuePairs.Add(i, "1361,Johab,Korean (Johab)");
                        i++;
                        keyValuePairs.Add(i, "10000,macintosh,Western European (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10001,x-mac-japanese,Japanese (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10002,x-mac-chinesetrad,Chinese Traditional (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10003,x-mac-korean,Korean (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10004,x-mac-arabic,Arabic (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10005,x-mac-hebrew,Hebrew (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10006,x-mac-greek, Greek (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10007,x-mac-cyrillic,Cyrillic (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10008,x-mac-chinesesimp,Chinese Simplified (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10010,x-mac-romanian,Romanian (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10017,x-mac-ukrainian,Ukrainian (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10021,x-mac-thai,Thai (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10029,x-mac-ce,Central European (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10079,x-mac-icelandic,Icelandic (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10081,x-mac-turkish,Turkish (Mac)");
                        i++;
                        keyValuePairs.Add(i, "10082,x-mac-croatian,Croatian (Mac)");
                        i++;
                        keyValuePairs.Add(i, "20000,x-Chinese-CNS,Chinese Traditional (CNS)");
                        i++;
                        keyValuePairs.Add(i, "20001,x-cp20001,TCA Taiwan");
                        i++;
                        keyValuePairs.Add(i, "20002,x-Chinese-Eten,Chinese Traditional (Eten)");
                        i++;
                        keyValuePairs.Add(i, "20003,x-cp20003,IBM5550 Taiwan");
                        i++;
                        keyValuePairs.Add(i, "20004,x-cp20004,TeleText Taiwan");
                        i++;
                        keyValuePairs.Add(i, "20005,x-cp20005,Wang Taiwan");
                        i++;
                        keyValuePairs.Add(i, "20105,x-IA5,Western European (IA5)");
                        i++;
                        keyValuePairs.Add(i, "20106,x-IA5-German,German (IA5)");
                        i++;
                        keyValuePairs.Add(i, "20107,x-IA5-Swedish,Swedish (IA5)");
                        i++;
                        keyValuePairs.Add(i, "20108,x-IA5-Norwegian,Norwegian (IA5)");
                        i++;
                        keyValuePairs.Add(i, "20127,us-ascii,US-ASCII");
                        i++;
                        keyValuePairs.Add(i, "20261,x-cp20261,T.61");
                        i++;
                        keyValuePairs.Add(i, "20269,x-cp20269,ISO-6937");
                        i++;
                        keyValuePairs.Add(i, "20273,IBM273,IBM EBCDIC (Germany)");
                        i++;
                        keyValuePairs.Add(i, "20277,IBM277,IBM EBCDIC (Denmark-Norway)");
                        i++;
                        keyValuePairs.Add(i, "20278,IBM278,IBM EBCDIC (Finland-Sweden)");
                        i++;
                        keyValuePairs.Add(i, "20280,IBM280,IBM EBCDIC (Italy)");
                        i++;
                        keyValuePairs.Add(i, "20284,IBM284,IBM EBCDIC (Spain)");
                        i++;
                        keyValuePairs.Add(i, "20285,IBM285,IBM EBCDIC (UK)");
                        i++;
                        keyValuePairs.Add(i, "20290,IBM290,IBM EBCDIC (Japanese katakana)");
                        i++;
                        keyValuePairs.Add(i, "20297,IBM297,IBM EBCDIC (France)");
                        i++;
                        keyValuePairs.Add(i, "20420,IBM420,IBM EBCDIC (Arabic)");
                        i++;
                        keyValuePairs.Add(i, "20423,IBM423,IBM EBCDIC (Greek)");
                        i++;
                        keyValuePairs.Add(i, "20424,IBM424,IBM EBCDIC (Hebrew)");
                        i++;
                        keyValuePairs.Add(i, "20833,x-EBCDIC-KoreanExtended,IBM EBCDIC (Korean Extended)");
                        i++;
                        keyValuePairs.Add(i, "20838,IBM-Thai,IBM EBCDIC (Thai)");
                        i++;
                        keyValuePairs.Add(i, "20866,koi8-r,Cyrillic (KOI8-R)");
                        i++;
                        keyValuePairs.Add(i, "20871,IBM871,IBM EBCDIC (Icelandic)");
                        i++;
                        keyValuePairs.Add(i, "20880,IBM880,IBM EBCDIC (Cyrillic Russian)");
                        i++;
                        keyValuePairs.Add(i, "20905,IBM905,IBM EBCDIC (Turkish)");
                        i++;
                        keyValuePairs.Add(i, "20924,IBM00924,IBM Latin-1");
                        i++;
                        keyValuePairs.Add(i, "20932,EUC-JP,Japanese (JIS 0208-1990 and 0212-1990)");
                        i++;
                        keyValuePairs.Add(i, "20936,x-cp20936,Chinese Simplified (GB2312-80)");
                        i++;
                        keyValuePairs.Add(i, "20949,x-cp20949,Korean Wansung");
                        i++;
                        keyValuePairs.Add(i, "21025,cp1025,IBM EBCDIC (Cyrillic Serbian-Bulgarian)");
                        i++;
                        keyValuePairs.Add(i, "21866,koi8-u,Cyrillic (KOI8-U)");
                        i++;
                        keyValuePairs.Add(i, "28591,iso-8859-1,Western European (ISO)");
                        i++;
                        keyValuePairs.Add(i, "28592,iso-8859-2,Central European (ISO)");
                        i++;
                        keyValuePairs.Add(i, "28593,iso-8859-3,Latin 3 (ISO)");
                        i++;
                        keyValuePairs.Add(i, "28594,iso-8859-4,Baltic (ISO)");
                        i++;
                        keyValuePairs.Add(i, "28595,iso-8859-5,Cyrillic (ISO)");
                        i++;
                        keyValuePairs.Add(i, "28596,iso-8859-6,Arabic (ISO)");
                        i++;
                        keyValuePairs.Add(i, "28597,iso-8859-7,Greek (ISO)");
                        i++;
                        keyValuePairs.Add(i, "28598,iso-8859-8,Hebrew (ISO-Visual)");
                        i++;
                        keyValuePairs.Add(i, "28599,iso-8859-9,Turkish (ISO)");
                        i++;
                        keyValuePairs.Add(i, "28603,iso-8859-13,Estonian (ISO)");
                        i++;
                        keyValuePairs.Add(i, "28605,iso-8859-15,Latin 9 (ISO)");
                        i++;
                        keyValuePairs.Add(i, "29001,x-Europa,Europa");
                        i++;
                        keyValuePairs.Add(i, "38598,iso-8859-8-i,Hebrew (ISO-Logical)");
                        i++;
                        keyValuePairs.Add(i, "50220,iso-2022-jp,Japanese (JIS)");
                        i++;
                        keyValuePairs.Add(i, "50221,csISO2022JP,Japanese (JIS-Allow 1 byte Kana)");
                        i++;
                        keyValuePairs.Add(i, "50222,iso-2022-jp,Japanese (JIS-Allow 1 byte Kana - SO/SI)");
                        i++;
                        keyValuePairs.Add(i, "50225,iso-2022-kr,Korean (ISO)");
                        i++;
                        keyValuePairs.Add(i, "50227,x-cp50227,Chinese Simplified (ISO-2022)");
                        i++;
                        keyValuePairs.Add(i, "51932,euc-jp,Japanese (EUC)");
                        i++;
                        keyValuePairs.Add(i, "51936,EUC-CN,Chinese Simplified (EUC)");
                        i++;
                        keyValuePairs.Add(i, "51949,euc-kr,Korean (EUC)");
                        i++;
                        keyValuePairs.Add(i, "52936,hz-gb-2312,Chinese Simplified (HZ)");
                        i++;
                        keyValuePairs.Add(i, "54936,GB18030,Chinese Simplified (GB18030)");
                        i++;
                        keyValuePairs.Add(i, "57002,x-iscii-de,ISCII Devanagari");
                        i++;
                        keyValuePairs.Add(i, "57003,x-iscii-be,ISCII Bengali");
                        i++;
                        keyValuePairs.Add(i, "57004,x-iscii-ta,ISCII Tamil");
                        i++;
                        keyValuePairs.Add(i, "57005,x-iscii-te,ISCII Telugu");
                        i++;
                        keyValuePairs.Add(i, "57006,x-iscii-as,ISCII Assamese");
                        i++;
                        keyValuePairs.Add(i, "57007,x-iscii-or,ISCII Oriya");
                        i++;
                        keyValuePairs.Add(i, "57008,x-iscii-ka,ISCII Kannada");
                        i++;
                        keyValuePairs.Add(i, "57009,x-iscii-ma,ISCII Malayalam");
                        i++;
                        keyValuePairs.Add(i, "57010,x-iscii-gu,ISCII Gujarati");
                        i++;
                        keyValuePairs.Add(i, "57011,x-iscii-pa,ISCII Punjabi");
                        i++;
                        keyValuePairs.Add(i, "65000,utf-7,Unicode (UTF-7)");
                        i++;
                        keyValuePairs.Add(i, "65001,utf-8,Unicode (UTF-8)");
                        i++;
                        keyValuePairs.Add(i, "65005,utf-32,Unicode (UTF-32)");
                        i++;
                        keyValuePairs.Add(i, "65006,utf-32BE,Unicode (UTF-32 Big-Endian)");



                        CEncoding cEncoding = new CEncoding();
                        foreach (var keyValuePairsItem in keyValuePairs)
                        {
                            string[] sEncodingValue = keyValuePairsItem.Value.Split(',');
                            cEncoding = new CEncoding
                            {
                                CodePage = Convert.ToInt32(sEncodingValue[0]),
                                Name = sEncodingValue[1],
                                DisplayName = sEncodingValue[2]
                            };
                            CEncodingListinstance.cEncodings.Add(cEncoding);
                        }
                    }
                }
                return CEncodingListinstance;
            }
        }

        private static CEncodingList CEncodingListinstance = null;

        private static object CEncodingListLock = new object();//加锁，防止多线程

        public List<CEncoding> cEncodings = new List<CEncoding>();
    }

    public class CEncoding
    {
        public int CodePage { get; set; }
        public string Name { get; set; }
        public string DisplayName { get; set; }
    }
}
